Skip to content

Improve documentation on duplex.rs #15182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed

Improve documentation on duplex.rs #15182

wants to merge 5 commits into from

Conversation

darnuria
Copy link
Contributor

Adding example and short documentation for methods.

@schmee
Copy link
Contributor

schmee commented Jun 25, 2014

The short documentation doesn't really add much understanding. Maybe you could try to adapt (or refer to) the thorough documentation from Sender and Receiver instead?

@darnuria
Copy link
Contributor Author

@schmee Nice idea. It's possible to make an internal link in the documentation?
If not I can adapt.

pub fn send(&self, x: S) {
self.tx.send(x)
}

/// Send optionnaly data to the channel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misspelling, and I'd say "Optionally send data to the channel."

@steveklabnik
Copy link
Member

I do think that this could be even better, but it's a great start, especially with a running example.

@darnuria
Copy link
Contributor Author

Yep I will add commits until it's done. Thanks for reviews.

pub fn send(&self, x: S) {
self.tx.send(x)
}

/// Optionally send data to the channel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I were unsure what send_opt did, this documentation doesn't really help me much because it just takes the 8-letter method name and expands it to a bit of english.

If we're adding documentation to these methods, then this should document the semantics of why it exists, what's optional about it, etc. This also applies to the documentation below as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Examples (preferably both the Ok and Err cases) would help.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an example and will try to adapt documentation from both Sender and Receiver for DuplexStream.
I am totally agree with you that just putting a sentence is not meaningful. :)

/// std::io::timer::sleep(1000);
/// assert_eq!(left.send_opt("ABC".to_string()),
/// Err("ABC".to_string()));
/// ```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is definitely helpful, but I think it still needs to be accompanied with words explaining the semantics of this function. The nonstandard functions below should also receive the same treatment.

Additionally, relying on sleep for correctness is likely to go wrong quickly. You can probably do this in a single-threaded situation without extra tasks.

@darnuria
Copy link
Contributor Author

darnuria commented Jul 5, 2014

Due to a future deprecation (see 58133ae) of this file I close this pull-request.

@darnuria darnuria closed this Jul 5, 2014
@darnuria darnuria deleted the improving_doc_libsync branch July 5, 2014 21:42
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2023
Disable mir interpreter for targets with different pointer size from host

fix rust-lang#15182
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants